package com.qiezi.project.adapter;

import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.qiezi.R;
import com.qiezi.base.BaseRecyclerAdapter;
import com.qiezi.bean.CategoryTwoBean;


public class CategoryAdapter extends BaseRecyclerAdapter<CategoryTwoBean> {


    public class VH extends Holder{

        SimpleDraweeView iv;
        TextView tvTitle;

        public VH(View itemView) {
            super(itemView);
            iv = itemView.findViewById(R.id.iv_image);
            tvTitle = itemView.findViewById(R.id.tv_title);
        }

        public void setData(CategoryTwoBean data){
            Uri uri = Uri.parse(data.getImage());
            iv.setImageURI(uri);
//            Picasso.get().load(data.getImage()).error(R.drawable.ic_load_error).into(iv);
            tvTitle.setText(data.getName());
        }
    }


    @Override
    public RecyclerView.ViewHolder onCreate(ViewGroup viewGroup, int viewType) {
        View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_category, viewGroup, false);
        return new VH(v);
    }



    @Override
    public void onBind(RecyclerView.ViewHolder viewHolder, int RealPosition, CategoryTwoBean data) {
        ((VH)viewHolder).setData(data);
    }
}
